package com.cxso.example.request.report;

import com.cxso.example.enums.report.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

@Getter
@Setter
public class ReportWaybillRequest implements Serializable {

    @NotBlank
    @Schema(description = "主体id")
    private String bodyId;

    @Schema(description = "运单号", example = "561256488")
    @NotBlank(message = "运单号不能为空")
    private String shippingNoteNumber;

    @Schema(description = "运输组织类型代码", example = "561256488")
    @NotNull(message = "运输组织类型代码不能为空")
    private TransportTypeEnum transportTypeCode;

    @Schema(description = "业务类型代码", example = "GANXIAN")
    @NotNull(message = "业务类型代码不能为空")
    private BusinessTypeEnum businessTypeCode;

    @Pattern(regexp = "^\\d{4}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])([01]\\d|2[0-4])([0-5]\\d)([0-5]\\d)$", message = "运单生成时间格式不正确")
    @Schema(description = "运单生成时间", example = "20200110180000")
    @NotBlank(message = "运单生成时间不能为空")
    private String consignmentDateTime;

    @Pattern(regexp = "^\\d{4}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])([01]\\d|2[0-4])([0-5]\\d)([0-5]\\d)$", message = "发货日期时间格式不正确")
    @Schema(description = "发货日期时间", example = "20200110180000")
    private String despatchActualDateTime;

    @Schema(description = "托运人名称", example = "杰克")
    @NotBlank(message = "托运人名称不能为空")
    private String consignor;

    @Schema(description = "托运人同意社会信用代码或个人证件号", example = "561256488")
    @NotBlank(message = "托运人同意社会信用代码或个人证件号不能为空")
    private String consignorId;

    @Schema(description = "托运人统一社会信用代码或个人证件号照片")
    private String consignorImg;

    @Schema(description = "托运联系人")
    private String linkPerson;

    @Schema(description = "托运联系人电话")
    private String linkPhone;

    @Schema(description = "装货地点", example = "561256488")
    @NotBlank(message = "装货地点不能为空")
    private String placeOfLoading;

    @Schema(description = "装货经度", example = "561256488")
    private String deliverLon;

    @Schema(description = "装货纬度", example = "561256488")
    private String deliverLat;

    @Schema(description = "发货省", example = "湖北省")
    @NotBlank(message = "发货省份不能为空")
    private String deliverProvince;

    @Schema(description = "发货市", example = "武汉市")
    @NotBlank(message = "发货市不能为空")
    private String deliverCity;

    @Schema(description = "发货区县", example = "江夏区")
    @NotBlank(message = "发货区县不能为空")
    private String deliverCounty;

    @Schema(description = "收货方名称", example = "561256488")
    @NotBlank(message = "收货方名称不能为空")
    private String consignee;

    @Schema(description = "收货方统一社会信用代码或个人证件号码", example = "561256488")
    @NotBlank(message = "收货方统一社会信用代码或个人证件号码不能为空")
    private String consigneeId;

    @Schema(description = "收货方联系电话", example = "561256488")
    private String consigneeTel;

    @Schema(description = "收货地址", example = "561256488")
    @NotBlank(message = "收货地址不能为空")
    private String goodsReceiptPlace;

    @Schema(description = "收货经度", example = "561256488")
    private String receivingLon;

    @Schema(description = "收货纬度", example = "561256488")
    private String receivingLat;

    @Schema(description = "收货方省", example = "湖北省")
    @NotBlank(message = "收货方省份不能为空")
    private String receivingProvince;

    @Schema(description = "收货方市", example = "武汉市")
    @NotBlank(message = "市不能为空")
    private String receivingCity;

    @Schema(description = "收货方区县", example = "江夏区")
    @NotBlank(message = "收货方区县不能为空")
    private String receivingCounty;

    @Schema(description = "实际承运人名称", example = "561256488")
//    @NotBlank(message = "实际承运人名称不能为空")
    private String actualCarrierName;

    @Schema(description = "实际承运人统一社会信用代码或证件号码", example = "实际承运人统一社会信用代码或证件号码")
//    @NotBlank(message = "实际承运人统一社会信用代码或证件号码不能为空")
    private String actualCarrierId;

    @Schema(description = "实际承运人的道路运输经营许可证编号", example = "实际承运人的道路运输经营许可证编号，网络货运经营者整合车辆全部为总质量4.5吨及以下普通货运车辆的，可填“车籍地6位行政区域代码+000000”")
//    @NotBlank(message = "实际承运人的道路运输经营许可证编号不能为空")
    private String actualCarrierBusinessLicense;

    @Schema(description = "道路运输经营许可证有限期自")
    @Pattern(regexp = "^\\d{4}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])$", message = "道路运输经营许可证有限期自格式不正确")
    private String actualCarrierBusinessLicenseFrom;

    @Schema(description = "道路运输经营许可证有限期至")
    @Pattern(regexp = "^\\d{4}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])$", message = "道路运输经营许可证有限期至格式不正确")
    private String actualCarrierBusinessLicenseTo;

    @Schema(description = "保险单号", example = "111")
    private String policyNumber;

    @Schema(description = "保险公司", example = "ABIC")
    private InsuranceCompanyEnum insuranceCompany;

    @Schema(description = "预计收货日期时间")
    @Pattern(regexp = "^\\d{4}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])([01]\\d|2[0-4])([0-5]\\d)([0-5]\\d)$", message = "预计收货日期时间格式不正确")
    private String goodsReceiptDateTime;

    @Schema(description = "运费金额，保留三位小数", example = "100 托运人与网络货运经营者签订运输合同确定的运费金额，货币单位为人民币（元），保留3位小数，如整数的话，以.000填充。如是一笔业务分几辆车运，需将托运人针对这笔业务付给网络货运经营者的运输费用分摊到每辆车上。")
    @NotBlank(message = "运费金额不能为空")
    private String totalMonetaryAmount;

    @Schema(description = "运单运费金额(不含运费差价)，保留三位小数", example = "100 托运人与网络货运经营者签订运输合同确定的运费金额，货币单位为人民币（元），保留3位小数，如整数的话，以.000填充。如是一笔业务分几辆车运，需将托运人针对这笔业务付给网络货运经营者的运输费用分摊到每辆车上。")
    private String waybillFreightAmount;

    @Schema(description = "司机收款金额")
    private String totalDriverFreight;

    @Schema(description = "车辆牌照号", example = "蒙L33603")
    @NotBlank(message = "车辆牌照号不能为空")
    private String vehicleNumber;

    @Schema(description = "车牌颜色代码", example = "1")
    @NotNull(message = "车牌颜色代码不能为空")
    private CarColorEnum vehiclePlateColorCode;


    @Schema(description = "司机姓名", example = "杰克")
    @NotBlank(message = "司机姓名不能为空")
    private String driverName;

    @Schema(description = "司机身份证号", example = "420281199910101234")
    @NotBlank(message = "司机身份证号不能为空")
    private String drivingLicense;


    @Schema(description = "货物信息", example = "如一车货有不同货物，则可循环。")
    @NotEmpty(message = "货物信息不能为空")
    private List<GoodsInfoDomain> goodsInfo;


    @Getter
    @Setter
    public static class GoodsInfoDomain {

        @Schema(description = "货物名称")
        private String descriptionOfGoods;

        @Schema(description = "货物类型分类代码")
        private GoodsTypeEnum cargoTypeClassificationCode;

        @Schema(description = "货物项毛重")
        private BigDecimal goodsItemGrossWeight;

        @Schema(description = "体积")
        private BigDecimal cube;

        @Schema(description = "总件数")
        private BigDecimal totalNumberOfPackages;

    }


    @Schema(description = "运输总车辆数")
    private Integer vehicleAmount;

    @Schema(description = "运单起运时间")
    @Pattern(regexp = "^\\d{4}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])([01]\\d|2[0-4])([0-5]\\d)([0-5]\\d)$", message = "运单起运时间格式不正确")
    private String departureTime;

    @Schema(description = "运单运抵时间")
    @Pattern(regexp = "^\\d{4}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])([01]\\d|2[0-4])([0-5]\\d)([0-5]\\d)$", message = "运单运抵时间格式不正确")
    private String arrivalTime;

    @Schema(description = "运输组货方式代码")
    private GoodsTransportTypeEnum goodsArrangementTypeCode;

    @Schema(description = "承运合同编号")
    private String commercialContractNumber;

    @Schema(description = "委托合同编号")
    private String contractNumber;

    @Schema(description = "委托合同(框架)编号")
    private String frameContractNumber;

    @Schema(description = "起运磅票")
    private String startTicketFileUrl;

    @Schema(description = "承运合同中约定甲方付款时间")
    @Pattern(regexp = "^\\d{4}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])$", message = "承运合同中约定甲方付款时间格式不正确")
    private String promisePayTime;

    @Schema(description = "到运磅票")
    private String arrivalTicketFileUrl;

    @Schema(description = "ETC发票地址")
    private String etcFileUrl;

    @Schema(description = "是否同城")
    private Boolean isLocalCity;

}
